package com.southwind.controller;


import com.southwind.common.Cache;
import com.southwind.common.TreeNode;
import com.southwind.entity.Menu;
import com.southwind.service.MenuService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author admin
 * @since 2024-12-17
 */
@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private MenuService menuService;

    @GetMapping("/leftMenu")
    public List<TreeNode> leftMenu(){
        List<Menu> list = this.menuService.list();
        List<TreeNode> result = new ArrayList<>();
        for (Menu menu : list) {
            TreeNode treeNode = new TreeNode();
            BeanUtils.copyProperties(menu, treeNode);
            result.add(treeNode);
        }
        return result;
    }
}

